package com.qf.fmall2203.comments.controller;

import com.qf.fmall2203.comments.entity.CommentsVo;
import com.qf.fmall2203.comments.service.IProductCommentsService;
import com.qf.fmall2203.utils.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 商品评价  前端控制器
 * </p>
 *
 * @author CM
 * @since 2023-02-14
 */
@RestController
@RequestMapping("/product")
@CrossOrigin
public class ProductCommentsController {

    @Autowired
    IProductCommentsService productCommentsService;


    @GetMapping("/detail-commontscount/{id}")
    public ResultVo comments(@PathVariable("id") Integer id){


        CommentsVo commentsVo = productCommentsService.getComment(id);


        return ResultVo.ok(commentsVo);
    }

    @GetMapping("/detail-commonts/{id}")
    public Map<String,Object> userComment(@PathVariable("id") Integer id,Integer pageNum,Integer limit){

        HashMap<String, Object> map1 = new HashMap<>();

        Map<String,Object> map = productCommentsService.getUserComment(id,pageNum,limit);
        map1.put("code",10000);
        map1.put("msg","sucess");
        map1.put("data",map);

        return map1;

    }

}
